package com.itguigu.glimail.order.vo;

import lombok.Getter;
import lombok.Setter;

import java.math.BigDecimal;
import java.util.List;
import java.util.Map;

/**
 * 封装确认订单结果
 */

public class OrderConfirmVo {
    //收货地址列表
    @Getter
    @Setter
    List<MemberAddressVo> address;
    //所有选中的购物项
    @Getter
    @Setter
    List<OrderItemVo> items;
    //发票....
    //优惠券信息
    @Getter
    @Setter
    private Integer integration;
    @Getter
    @Setter
    String orderToken;//防虫令牌
    Integer count;
    @Getter
    @Setter
    Map<Long, Boolean> stock;

    public Integer getCount() {
        Integer i = 0;
        if (items != null && items.size() > 0) {
            for (OrderItemVo item : items) {
                i += item.getCount();
            }
        }
        return i;
    }
    //    BigDecimal total; //订单总额


    public BigDecimal getTotal() {
        BigDecimal sum = new BigDecimal("0");
        if (items != null && items.size() > 0) {
            for (OrderItemVo item : items) {
                BigDecimal multiply = item.getPrice().multiply(new BigDecimal(item.getCount().toString()));
                sum = sum.add(multiply);
            }
        }
        return sum;
    }

//    BigDecimal payPrice;//应付价格

    public BigDecimal getPayPrice() {


        return getTotal();
    }
}
